/*
 *  Copyright (c) 2011, StripBandunk and/or its affiliates. All rights reserved.
 * 
 *       http://stripbandunk.com/
 * 
 *  STRIPBANDUNK PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * Form.java
 *
 * Created on Aug 30, 2011, 12:46:12 PM
 */
package com.stripbandunk.tutorial.customizemessagebox.widget;

import com.stripbandunk.tutorial.customizemessagebox.helper.MessageBoxCreator;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Eko Kurniawan Khannedy
 */
public class Form extends javax.swing.JFrame {

    private static final long serialVersionUID = 1L;

    /** Creates new form Form */
    public Form() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonHapus = new javax.swing.JButton();
        buttonBukaWebsite = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("StripBandunk");

        buttonHapus.setText("Hapus");
        buttonHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonHapusActionPerformed(evt);
            }
        });

        buttonBukaWebsite.setText("Buka Website");
        buttonBukaWebsite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonBukaWebsiteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonHapus)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonBukaWebsite)
                .addContainerGap(348, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonHapus)
                    .addComponent(buttonBukaWebsite))
                .addContainerGap(299, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-543)/2, (screenSize.height-357)/2, 543, 357);
    }// </editor-fold>//GEN-END:initComponents

private void buttonHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHapusActionPerformed
    // TODO add your handling code here:
    int result = MessageBoxCreator.showQuestionBox(this, "Hapus", "Anda tidak akan dapat mengembalikan \ndata yang telah dihapus.", new String[]{"Hapus", "Batalkan"}, 0);
    if (result == 0) {
        Logger.getLogger(Form.class.getName()).info("Anda Melakukan Penghapusan");
    } else {
        Logger.getLogger(Form.class.getName()).info("Anda Membatalkan Penghapusan");
    }
}//GEN-LAST:event_buttonHapusActionPerformed

private void buttonBukaWebsiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBukaWebsiteActionPerformed
    // TODO add your handling code here:
    int result = MessageBoxCreator.showQuestionBox(this, "Buka Website", "Aplikasi akan membuka website StripBandunk \nhttp://stripbandunk.com/", new String[]{"Buka Website", "Batalkan"}, 0);
    if (result == 0) {
        try {
            Desktop desktop = Desktop.getDesktop();
            desktop.browse(new URI("http://stripbandunk.com/"));
        } catch (IOException ex) {
            Logger.getLogger(Form.class.getName()).log(Level.SEVERE, null, ex);
        } catch (URISyntaxException ex) {
            Logger.getLogger(Form.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        Logger.getLogger(Form.class.getName()).info("Anda Membatalkan Membuka Website StripBandunk");
    }
}//GEN-LAST:event_buttonBukaWebsiteActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonBukaWebsite;
    private javax.swing.JButton buttonHapus;
    // End of variables declaration//GEN-END:variables
}
